package com.sql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public abstract class Init {
	
	public Connection SqlInit(){
		Connection con=null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			String url="jdbc:mysql://192.168.1.157:3306/shopping?useUnicode=true&characterEncoding=utf-8&useSSL=true";
			String username="tyhCentos";
			String password="aaa321!";
			con=DriverManager.getConnection(url,username,password);
			System.out.println("数据库连接成功...");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			System.out.println("驱动加载失败...");
		} catch (SQLException e) {
			e.printStackTrace();
			System.out.println("数据库连接失败...");
		}
		return con;
	}

}
